using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DataAccess;
using Entity; 

namespace Business
{
    public class bOrderDetail
    {
        public static int insertOrderDetail(eOrderDetail orderDetail)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@OrderID", SqlDbType.Int);
            pr.Value = orderDetail.OrderID;
            paramList.Add(pr);

            pr = new SqlParameter("@PlanDetailID", SqlDbType.Int);
            pr.Value = orderDetail.PlanDetailID;
            paramList.Add(pr);

            pr = new SqlParameter("@Amount", SqlDbType.Int);
            pr.Value = orderDetail.Amount;
            paramList.Add(pr);
            int r = dbh.ExecuteNonQuery("insertOrderDetail", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return r;
        }
        public static DataTable getAllOrderDetailByOrderID(String OrderID)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();

            SqlParameter pr = new SqlParameter("@OrderID", SqlDbType.VarChar);
            pr.Value = OrderID;
            paramList.Add(pr);

            DataTable dt = dbh.ExecuteQueryDataTable("getAllOrderDetailByOrderID", CommandType.StoredProcedure,paramList);
            dbh.CloseConnection();
            return dt;
        }
    }
}
